package com.bclz.task;

import java.io.IOException;
import java.util.Iterator;

import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Reducer;

/**
 * 
* @ClassName: WordCountReduceTask  
* @Description: reduce方法实现  
* @author xuchang  
* @date 2018年9月18日
 */
public class WordCountReduceTask extends Reducer<Text, IntWritable, Text, IntWritable> {
	@Override
	protected void reduce(Text key, Iterable<IntWritable> values,Context result) throws IOException, InterruptedException {
		// TODO Auto-generated method stub
		int count=0;
		Iterator<IntWritable> iterator = values.iterator();
		while(iterator.hasNext()) {
			
			count+=iterator.next().get();
			
		}
		result.write(key, new IntWritable(count));
		
	}
}
